home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
.net 2002 March
/
DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin
/
pc
/
PC Software
/
free_browsing
/
DavesQckSearchDbar3-14
/
dqsd.exe
/
searches
/
rnum.xml
< prev
next >
Wrap
Text File
|
2002-09-06
|
3KB
|
98 lines
<search function="rnum">
<name>Roman Numeral Generator</name>
<description>
Generate Roman numeral equivalents to decimal numbers.<br/>
<div class="helpboxDescLabels">Usage:</div>
<table class="helpboxDescTable">
<tr><td>rnum <<i>decimal number between 1 and 3999</i>></td></tr>
</table>
<a class="helpboxDescLabels">Example:</a><br/>
<table class="helpBoxDescTable">
<tr><td class="helpboxDescColumns">rnum 1996</td></tr>
</table>
</description>
<category>Functions</category>
<contributor>Monty Scroggins</contributor>
<script><![CDATA[
function rnum(number)
{
if( nullArgs("rnum",number) )
return false;
if((parseInt(number) < 4000) && (parseInt(number) > 0))
{
var ones_numerals = new Array();
ones_numerals[0] = "";
ones_numerals[1] = "I";
ones_numerals[2] = "II";
ones_numerals[3] = "III";
ones_numerals[4] = "IV";
ones_numerals[5] = "V";
ones_numerals[6] = "VI";
ones_numerals[7] = "VII";
ones_numerals[8] = "VIII";
ones_numerals[9] = "IX";
var tens_numerals = new Array();
tens_numerals[0] = "";
tens_numerals[1] = "X";
tens_numerals[2] = "XX";
tens_numerals[3] = "XXX";
tens_numerals[4] = "XL";
tens_numerals[5] = "L";
tens_numerals[6] = "LX";
tens_numerals[7] = "LXX";
tens_numerals[8] = "LXXX";
tens_numerals[9] = "XC";
var hundreds_numerals = new Array();
hundreds_numerals[0] = "";
hundreds_numerals[1] = "C";
hundreds_numerals[2] = "CC";
hundreds_numerals[3] = "CCC";
hundreds_numerals[4] = "CD";
hundreds_numerals[5] = "D";
hundreds_numerals[6] = "DC";
hundreds_numerals[7] = "DCC";
hundreds_numerals[8] = "DCCC";
hundreds_numerals[9] = "CM";
var thousands_numerals = new Array();
thousands_numerals[0] = "";
thousands_numerals[1] = "M";
thousands_numerals[2] = "MM";
thousands_numerals[3] = "MMM";
var new_num = number;
var thousands = Math.floor(new_num / 1000);
new_num -= thousands * 1000;
var hundreds = Math.floor(new_num / 100);
new_num -= hundreds * 100;
var tens = Math.floor(new_num / 10);
new_num -= tens * 10;
var ones = Math.floor(new_num / 1);
var array = new Array(thousands,hundreds,tens,ones);
var numeral = "";
numeral += thousands_numerals[array[0]];
numeral += hundreds_numerals[array[1]];
numeral += tens_numerals[array[2]];
numeral += ones_numerals[array[3]];
document.deff.q.value = numeral;
}
else
{
alert('you must enter a valid number between 0 and 4000.');
}
}//function makenumeral
]]></script>
<copyright>
Copyright (c) 2002 David Bau
Distributed under the terms of the
GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
</copyright>
</search>